﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CameraController : MonoBehaviour
{

    public GameObject target;
    public float fixedZ = -10f;
    public float lerpRate = 4f;


    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        if (target)
        {
            Vector2 curLoc = transform.position;
            Vector2 tarLoc = target.transform.position;
            Vector2 nextLoc = Vector2.Lerp(transform.position, target.transform.position, lerpRate * Time.deltaTime);
            transform.position = new Vector3(nextLoc.x, nextLoc.y, fixedZ);
        }
    }
}
